<?php
/*
 *    $Id: wsdlclient3.php,v 1.3 2004/06/25 13:21:22 snichol Exp $
 *
 *    WSDL client sample.
 *
 *    Service: WSDL
 *    Payload: rpc/encoded
 *    Transport: http
 *    Authentication: none
 */
require_once('../../../../../init.php');
Module_Loader::load_nusoap();
// require_once('../lib/nusoap.php');
$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
$client = new nusoap_client('http://www.scottnichol.com/samples/hellowsdl2.php?wsdl', true,
                        $proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client->getError();
if ($err) {
    echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}
$person = array('firstname' => 'Willi', 'age' => 22, 'gender' => 'male');
$method = isset($_GET['method']) ? $_GET['method'] : 'function';
if ($method == 'function') {
    $call = 'hello';
} elseif ($method == 'instance') {
    $call = 'hellowsdl2.hello';
} elseif ($method == 'class') {
    $call = 'hellowsdl2..hello';
} else {
    $call = 'hello';
}
$result = $client->call($call, array('person' => $person));
// Check for a fault
if ($client->fault) {
    echo '<h2>Fault</h2><pre>';
    print_r($result);
    echo '</pre>';
} else {
    // Check for errors
    $err = $client->getError();
    if ($err) {
        // Display the error
        echo '<h2>Error</h2><pre>' . $err . '</pre>';
    } else {
        // Display the result
        echo '<h2>Result</h2><pre>';
        print_r($result);
        echo '</pre>';
    }
}
echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
?>
